<?php
/**
 * XArrayObject element object class
 *
 * @category XArrayObject
 * @package XPHPFramework
 * @author chopins xiao <chopins.xiao@gmail.com>
 */
class XArrayElementObject {
    /**
     * save element value
     *
     * @var mixed
     * @access public
     */
    public $value;
    public $name;

    public function __construct($value, $name = '') {
        $this->value = $value;
        $this->name = $name;
    }
    public function __toString() {
        return $this->value;
    }
    public function __set($name,$value) {
        if(is_array($value)) {
            $this->$name = new XArrayObject($value);
        } else if(is_object($value) || is_resource($value)) {
            $this->$name = $value;
        } else {
            $this->$name = new XArrayElementObject($value);
        }
    }
}
